

import 'package:huajianshe_app/network/response/BaseResp.dart';
import 'package:huajianshe_app/pages/circle/model/CircleModel.dart';
import 'package:huajianshe_app/pages/main/model/MomentModel.dart';
import 'package:json_annotation/json_annotation.dart';

part 'LessonModel.g.dart';

@JsonSerializable()
class LessonHomeResp extends BaseResp {

  LessonHomeData? data;

  LessonHomeResp();

  factory LessonHomeResp.fromJson(Map<String, dynamic> json) => _$LessonHomeRespFromJson(json);

  @override
  LessonHomeResp parseFromMap(Map<String, dynamic> map) {
    return LessonHomeResp.fromJson(map);
  }
}

@JsonSerializable()
class LessonHomeData {

  @JsonKey(name: 'banner_list')
  List<Banner>? banners;

  @JsonKey(name: 'category_list')
  List<Category>?  categories;

  @JsonKey(name: 'hot_list')
  List<Lesson>? hots;

  @JsonKey(name: 'new_sale_list')
  List<Lesson>? newSales;

  LessonHomeData();

  factory LessonHomeData.fromJson(Map<String, dynamic> json) => _$LessonHomeDataFromJson(json);

}

@JsonSerializable()
class Banner {
  int? id;
  String? title;
  @JsonKey(name: 'icon_url')
  String? url;
  @JsonKey(name: 'target_type')
  int? targetType;
  @JsonKey(name: 'target_id')
  int? targetId;

  Banner();

  factory Banner.fromJson(Map<String, dynamic> json) => _$BannerFromJson(json);
}

@JsonSerializable()
class Category {
  int? id;
  @JsonKey(name: 'category_name')
  String? name;
  @JsonKey(name: 'icon_url')
  String? url;
  Category();


  factory Category.fromJson(Map<String, dynamic> json) => _$CategoryFromJson(json);
}

@JsonSerializable()
class Lesson {
  int? id;
  @JsonKey(name: 'lesson_sn')
  String? lessonSn;
  @JsonKey(name: 'lesson_name')
  String? name;
  @JsonKey(name: 'cover_url')
  String? cover;
  String? price;
  String? desc;
  @JsonKey(name: 'master_name')
  String? teacher;
  @JsonKey(name: 'panic_buying_status') //是否限时抢购
  int? status;
  @JsonKey(name: 'chapter_number')
  int? num;

  Lesson();

  factory Lesson.fromJson(Map<String, dynamic> json) => _$LessonFromJson(json);
}

@JsonSerializable()
class LessonListResp extends BaseResp {
  LessonListPager? data;
  LessonListResp();

  factory LessonListResp.fromJson(Map<String, dynamic> json) => _$LessonListRespFromJson(json);

  @override
  LessonListResp parseFromMap(Map<String, dynamic> map) {
    return LessonListResp.fromJson(map);
  }
}

@JsonSerializable()
class LessonListPager extends Pager {
  List<Lesson>? data;
  LessonListPager();

  factory LessonListPager.fromJson(Map<String, dynamic> json) => _$LessonListPagerFromJson(json);
}

@JsonSerializable()
class LessonDetailResp extends BaseResp {
  LessonDetailData? data;

  LessonDetailResp();

  factory LessonDetailResp.fromJson(Map<String, dynamic> json) => _$LessonDetailRespFromJson(json);

  @override
  LessonDetailResp parseFromMap(Map<String, dynamic> map) {
    return LessonDetailResp.fromJson(map);
  }
}

@JsonSerializable()
class LessonDetailData {

  @JsonKey(name: 'lesson_sn')
  String? lessonSn;
  @JsonKey(name: 'lesson_name')
  String? name;
  // @JsonKey(name: 'cover_url')
  // String? cover;
  @JsonKey(name: 'pay_type') //1收费2免费
  int? payType;
  String? price;
  @JsonKey(name: 'lesson_content')
  String? content;
  @JsonKey(name: 'comment_num')
  int? commentNum;
  @JsonKey(name: 'collect_num')
  int? collectNum;
  @JsonKey(name: 'view_num')
  int? viewNum;
  @JsonKey(name: 'sales_volume_exp')
  String? saleNum;
  @JsonKey(name: 'play_num_exp')
  String? playNum;
  @JsonKey(name: 'has_buy')
  int? isBuyed;
  @JsonKey(name: 'need_buy') //是否需要购买
  int? needBuy;
  @JsonKey(name: 'is_collect')
  int? isCollected;
  @JsonKey(name: 'chapter_number')
  int? totalChapters;

  @JsonKey(name: 'current_chapter_number')
  int? currentChapter;

  @JsonKey(name: 'chapter_list')
  List<Chapter>? chapters;
  @JsonKey(name: 'circle_info')
  CircleInfo? circleInfo;

  @JsonKey(name: 'demo_chapter_type')
  int? chapterType;
  @JsonKey(name: 'demo_cover_url')
  String? cover;
  @JsonKey(name: 'demo_video_url')
  String? videoUrl;
  @JsonKey(name: 'demo_video_length')
  String? length;
  @JsonKey(name: 'lesson_h5')
  String? lessonH5;
  @JsonKey(name: 'master_h5')
  String? masterH5;

  LessonDetailData();

  factory LessonDetailData.fromJson(Map<String, dynamic> json) => _$LessonDetailDataFromJson(json);
}

@JsonSerializable()
class Chapter {
  @JsonKey(name: 'chapter_type')
  int? type;
  @JsonKey(name: 'chapter_name')
  String? name;
  @JsonKey(name: 'cover_url')
  String? cover;
  @JsonKey(name: 'video_url')
  String? video;
  @JsonKey(name: 'video_length')
  String? length;

  Chapter();

  factory Chapter.fromJson(Map<String, dynamic> json) => _$ChapterFromJson(json);
}
